﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace ASPMVC_first_app.Models
{
    public class Min1Max20movies: ValidationAttribute
    {
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var movie = (Movie)validationContext.ObjectInstance;

            if (movie.Count >0 && movie.Count<=20)
                return ValidationResult.Success;

            else
                return new ValidationResult("Count of movies should be from 1 to 20");
            
        }
    }
}